﻿
Imports osi.fs.property

Public Class wrappered_property(Of T)
    Implements iproperty(Of T)

    Private ReadOnly p As iproperty(Of T) = Nothing

    Private Shared Function create(ByVal id As Int64, ByVal name As String, ByVal type As String,
                                   ByVal ParamArray wrappers() As [property].wrapper_d)
        assert(Not wrappers Is Nothing AndAlso wrappers.Length() > 0)
        Dim p As iproperty = Nothing
        p = New [property](id, name, type)
        For i As Int64 = 0 To wrappers.Length() - 1
            p = wrappers(i)(p)
        Next
        Return convertor.cast(Of iproperty(Of T))(p)
    End Function

    Protected Sub New(ByVal id As Int64, ByVal name As String, ByVal type As String,
                      ByVal ParamArray wrappers() As [property].wrapper_d)
        Me.New(create(id, name, type, wrappers))
    End Sub

    Protected Sub New(ByVal p As iproperty(Of T))
        assert(Not p Is Nothing)
        Me.p = p
    End Sub

    Public Function destroy() As eventComb Implements iproperty.destroy
        Return p.destroy()
    End Function

    Public Function get_data(ByVal data As pointer(Of T)) As eventComb Implements iproperty(Of T).get_data
        Return p.get_data(data)
    End Function

    Public Function get_set_data(ByVal d As _do(Of T, Boolean)) As eventComb _
                                Implements iproperty(Of T).get_set_data
        Return p.get_set_data(d)
    End Function

    Public Function get_set_data(ByVal d As get_set_data_d(Of T)) As eventComb _
                                Implements iproperty(Of T).get_set_data
        Return p.get_set_data(d)
    End Function

    Public Function set_data(ByVal value As T) As eventComb Implements iproperty(Of T).set_data
        Return p.set_data(value)
    End Function
End Class
